package com.example.myapplication.ui.notifications;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.example.myapplication.Entity.MessageEntity;
import java.util.ArrayList;
import java.util.List;
public class TalkingViewModel extends ViewModel {
    private MutableLiveData<List<MessageEntity>> messageList = new MutableLiveData<>();

    public void addMessage(MessageEntity message) {
        List<MessageEntity> currentList = messageList.getValue();
        if (currentList == null) {
            currentList = new ArrayList<>();
        }
        currentList.add(message);
        messageList.setValue(currentList);
    }

    public LiveData<List<MessageEntity>> getMessageList() {
        return messageList;
    }

}
